﻿using Microsoft.EntityFrameworkCore;

namespace RepositoryApp;
public class EfCoreRepository<TEntity> : IRepository<TEntity> where TEntity : class
{
    private readonly DbContext _context;

    public EfCoreRepository(DbContext context)
    {
        this._context = context;
    }

    public Task DeleteAsync(TEntity entity)
    {
        throw new NotImplementedException();
    }

    public Task<TEntity> GetByIdAsync(int id)
    {
        throw new NotImplementedException();
    }

    public Task<IEnumerable<TEntity>> GetListAsync()
    {
        return Task.FromResult(_context.Set<TEntity>()
            .ToList()
            .AsEnumerable());
    }

    public Task InsertAsync(TEntity entity)
    {
        _context.Set<TEntity>().Add(entity);
        return _context.SaveChangesAsync();
    }

    public Task UpdateAsync(TEntity entity)
    {
        throw new NotImplementedException();
    }
}
